package ltd.followkba;

import com.kcbsdk.MyWorks.AWorksType;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import ltd.advskin.MRAM;
import ltd.followkba.comment.bean.BUsage;
import ltd.followkba.task.BAppUser;
import ltd.followkba.task.BAppWorks;
import ltd.followkba.task.BCommentInfo;
import ltd.followkba.task.BDbsAccount;
import ltd.followkba.task.BFileBase;
import ltd.followkba.task.BRankInfo;
import ltd.followkba.task.BUploadPlan;
import ltd.followkba.task.BWorksList;
import ltd.followkba.task.LogTyp;
import main.MAPI;

import static ltd.advskin.MSKIN.MLOGE;
import static ltd.advskin.MSKIN.MSTRING;
import static ltd.advskin.MSKIN.MTOAST;
import static main.MAPI.mMyUtils;

public class MDBS {

    public final static int SVR_MIX = 64;                                   // 如果使用这个标志，所有享吧的WorksType转换为0x20，不区分各自的类型了
    public final static int SVR_LOGIN = 1 | SVR_MIX;                        // 登录信息
    public final static int SVR_ACCOUNT = 2 | SVR_MIX;                      // 账号信息
    public final static int SVR_COMMENT = 6;

    public static String gsRootPath;


    public static void MLOG(String text) {
        MSTRING("MDBS " + text);
    }

    public static void setRootPath() {
        gsRootPath = String.format("%sFollowKBa/", MRAM.gsRootPath);
        gsRootPath = gsRootPath.replace("/hsav/", "/");
        MDBS.checkPathExist(gsRootPath);
        MDBS.checkPathExist(getAccountPath());
        MDBS.checkPathExist(getTextPath());
    }
    public static String getAccountPath() {
        return String.format("%saccount/", MRAM.gsFilePath);
    }
    public static String getAccountPath(byte appType, String accountName) {
        return (accountName != null) ? String.format("%s%s_%s.bin", getAccountPath(), appType, accountName) : null;
    }
    public static String getTextPath() {
        return String.format("%stext/", MRAM.gsFilePath);
    }
    public static String getTextPath(byte appType, String accountName, int worksType, String key) {
        return String.format("%s%s_%s_%s_%s.bin", getTextPath(), appType, accountName, worksType, key);
    }
    public static String getUserPath(byte appType) {
        if (appType < 32) appType = 32;                         // 相同类型的账号，统一放在一个地方
        if (appType == 49) appType = 33;
        return String.format("%suser_%s/", gsRootPath, appType);
    }
    public static String getUserPath(byte appType, String userIdS) {
        return (userIdS != null) ? String.format("%s%s.bin", getUserPath(appType), userIdS) : null;
    }
    public static String getWorksPath(byte appType) {
        return String.format("%sworks_%s/", gsRootPath, appType);
    }
    public static String getWorksPath(byte appType, String userIds, String worksIdS) {
        return (userIds != null && worksIdS != null) ? String.format("%s%s_%s.bin", getWorksPath(appType), userIds, worksIdS) : null;
    }
    public static String getCommentPath(int appType) {
        return String.format("%scomment_%s/", gsRootPath, appType);
    }
    public static String getCommentPath(byte appType, String userIds, String worksIdS, String commentIdS) {
        return (userIds != null && worksIdS != null) ? String.format("%s%s_%s_%s.bin", getCommentPath(appType), userIds, worksIdS, commentIdS) : null;
    }


    public static String getDbsPath(byte appType) {
        return String.format("%sdbs_%s/", gsRootPath, appType);
    }
    public static String getListPath(byte appType, String userIdS) {
        return String.format("%slist_%s.bin", getDbsPath(appType), userIdS);
    }
    public static String getListPath(byte appType, String userIdS, String worksIdS) {
        return String.format("%slist_%s_%s.bin", getDbsPath(appType), userIdS, worksIdS);
    }

    public static String getLogPath(byte appType, LogTyp logTyp) {
        return String.format("%s%s/", getDbsPath(appType), logTyp);
    }
    public static String getRankCounterPath() {
        return String.format("%srank_count.bin/", MDBS.getDbsPath((byte) 32));
    }

    public static int getDbsId() {
        String filePath = String.format("%sdbsid.bin", getDbsPath((byte)32));
        Object object = MAPI.READ_OBJECT_FILE(filePath);
        int dbsId = (object instanceof Integer) ? (Integer)object : 0;
        MAPI.WRITE_OBJECT_FILE(filePath, ++dbsId);
//        MLOG(String.format("getDbsIdA %s", dbsId));
        return Math.abs(dbsId);
    }


    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // 用户BAppUser数据库，相同类型的账号，统一放在一个地方
    public static void setBAppUser(BAppUser bAppUser){
        if (bAppUser != null) {
            String filePath = getUserPath(bAppUser.WorksType, bAppUser.UserIdS);
            if (!MAPI.IS_EXIST_FILE(filePath)) {
                bAppUser.DateTime = mMyUtils.getCurrentDate();
                MAPI.WRITE_OBJECT_FILE(filePath, bAppUser);
            }
        }
    }
    public static BAppUser getBAppUser(byte appType, String userIdS){
        String filePath = getUserPath(appType, userIdS);
        Object object =  MAPI.READ_OBJECT_FILE(filePath);
        if (object instanceof BAppUser) {
            BAppUser bAppUser = (BAppUser)object;
            if (MAPP.checkOverHour(bAppUser.DateTime, 2)){
//                MLOGE(String.format("OverA A %s %s", mMyUtils.getSmartDate(bAppUser.DateTime), filePath));
                MAPI.DELETE_FILE(filePath);
            }
            return (BAppUser)object;
        }
        return null;
    }
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // 作品信息数据库
    public static void setBAppWorks(BAppWorks bAppWorks){
        if (bAppWorks != null) {
            String filePath = getWorksPath(bAppWorks.WorksType, bAppWorks.UserIdS, bAppWorks.WorksIdS);
            if (!MAPI.IS_EXIST_FILE(filePath)) {
                bAppWorks.DateTime = mMyUtils.getCurrentDate();
                MAPI.WRITE_OBJECT_FILE(filePath, bAppWorks);
            }
        }
    }
    public static BAppWorks getBAppWorks(byte appType, String userIdS, String worksIdS){
        String filePath = getWorksPath(appType, userIdS, worksIdS);
        Object object = MAPI.READ_OBJECT_FILE(filePath);
        if (object instanceof BAppWorks) {
            BAppWorks bAppWorks = (BAppWorks)object;
            if (MAPP.checkOverHour(bAppWorks.DateTime, 2)){
//                MLOGE(String.format("OverA B %s %s", mMyUtils.getSmartDate(bAppWorks.DateTime), filePath));
                MAPI.DELETE_FILE(filePath);
            }
            return (BAppWorks)object;

        }
        return null;
    }
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // 作品列表数据库
    public static void setWorksList(byte appType, String userIdS, String[] worksIdS, BWorksList bWorksList){
        String filePath = getListPath(appType, userIdS);
        if (bWorksList == null) {
            bWorksList = new BWorksList();
            bWorksList.WorksIdS = worksIdS;
        }
        bWorksList.DateTime = mMyUtils.getCurrentDate();
        MAPI.WRITE_OBJECT_FILE(filePath, bWorksList);
    }
    public static BWorksList getWorksList(byte appType, String userIdS){
        String filePath = getListPath(appType, userIdS);
        Object object = MAPI.READ_OBJECT_FILE(filePath);
        if (object instanceof BWorksList) {
            BWorksList bWorksList = (BWorksList)object;
            if (MAPP.checkOverHour(bWorksList.DateTime, 2)){
//                MLOGE(String.format("OverA C %s %s", mMyUtils.getSmartDate(bWorksList.DateTime), filePath));
                MAPI.DELETE_FILE(filePath);
            }
            return bWorksList;
        }
        return null;
    }
    public static void setWorks49List(String userIdS, BAppWorks[] bAppWorks){
        String filePath = getListPath((byte)49, userIdS);
        MAPI.WRITE_OBJECT_FILE(filePath, bAppWorks);
        Object object = MAPI.READ_OBJECT_FILE(filePath);
//        MLOG(String.format("HomeA AAA getWorks49List %s %s", object, filePath));
    }
    public static BAppWorks[] getWorks49List(String userIdS){
        String filePath = getListPath((byte)49, userIdS);
        Object object = MAPI.READ_OBJECT_FILE(filePath);
        if (object instanceof BAppWorks[]) {
            return (BAppWorks[]) object;
        }
        return null;
    }
//    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//    // 作品评论信息数据库
//    public static void setBCommentInfo(BCommentInfo bCommentInfo){
//        if (bCommentInfo != null) {
//            String filePath = getCommentPath(bCommentInfo.WorksType, bCommentInfo.UserIdS, bCommentInfo.IdS, bCommentInfo.CommentIdS);
//            if (!MAPI.IS_EXIST_FILE(filePath)) {
//                MAPI.WRITE_OBJECT_FILE(filePath, bCommentInfo);
//            }
//        }
//    }
//    public static BCommentInfo getBCommentInfo(int appType, String userIdS, String worksIdS, String commentIdS){
//        String filePath = getCommentPath(appType, userIdS, worksIdS, commentIdS);
//        Object object = MAPI.READ_OBJECT_FILE(filePath);
//        if (object instanceof BCommentInfo) {
//            return (BCommentInfo)object;
//
//        }
//        return null;
//    }
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // 作品评论列表数据库
    public static void setBCommentList(byte appType, String userIdS, String worksIdS, BCommentInfo[] bCommentInfo){
        if (bCommentInfo != null) {
            String filePath = getListPath(appType, userIdS, worksIdS);
            if (!MAPI.IS_EXIST_FILE(filePath)) {
                MAPI.WRITE_OBJECT_FILE(filePath, bCommentInfo);
            }
        }
    }
    public static BCommentInfo[] getBCommentList(byte appType, String userIdS, String worksIdS){
        String filePath = getListPath(appType, userIdS, worksIdS);
        Object object = MAPI.READ_OBJECT_FILE(filePath);
        if (object instanceof BCommentInfo[]) {
            return (BCommentInfo[])object;

        }
        return null;
    }




    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // 账号数据库
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public static String getAccountListPath(byte appType) {
        return String.format("%slist_%s.bin", getAccountPath(), appType);
    }
    public static void setBDbsAccount(BDbsAccount bDbsAccount){
        String filePath = getAccountPath(bDbsAccount.WorksType, bDbsAccount.AccountName);
        if (!MAPI.IS_EXIST_FILE(filePath)) {
            String listFile = getAccountListPath(bDbsAccount.WorksType);
            Object object = MAPI.READ_OBJECT_FILE(listFile);
            List<String> lists = (object instanceof List) ? (List)object : new ArrayList<String>();
            MSTRING(String.format("setBDbsAccount A %s(%s)%s(%s)", bDbsAccount.WorksType, bDbsAccount.AccountName, filePath, listFile));
            lists.add(bDbsAccount.AccountName);
            MAPI.WRITE_OBJECT_FILE(listFile, lists);
        }
        MAPI.WRITE_OBJECT_FILE(filePath, bDbsAccount);
    }
    public static void delBDbsAccount(BDbsAccount bDbsAccount){
        String listFile = getAccountListPath(bDbsAccount.WorksType);
        Object object = MAPI.READ_OBJECT_FILE(listFile);
        if (object instanceof List){
            List<String> lists = (List)object;
            lists.remove(bDbsAccount.AccountName);
            MAPI.WRITE_OBJECT_FILE(listFile, lists);
        }
        MAPI.DELETE_FILE(getAccountPath(bDbsAccount.WorksType, bDbsAccount.AccountName));
    }
    public static BDbsAccount getBDbsAccount(byte appType, String accountName){
        Object object = MAPI.READ_OBJECT_FILE(getAccountPath(appType, accountName));
        if (object instanceof BDbsAccount) {
            return (BDbsAccount) object;
        }
        return null;
    }
    public static List<BDbsAccount> getBDbsAccount(byte appType){
        String listFile = getAccountListPath(appType);
        Object object = MAPI.READ_OBJECT_FILE(listFile);
//        MLOG(String.format("makeBDbsAccount getBDbsAccount %s %s", object, listFile));
        if (object instanceof List){
            List<BDbsAccount> accounts = new ArrayList<>();
            List<String> lists = (List)object;
            int length = lists.size();
            for (int index = 0; index < length; index++){
                BDbsAccount bDbsAccount = getBDbsAccount(appType, lists.get(index));
                if (bDbsAccount != null){
                    accounts.add(bDbsAccount);
                }
            }
            return accounts;
        }
        return null;
    }
    public static BDbsAccount getBrotherAccount(byte worksType, String accountName){
        byte[] tabWorksType = {
                AWorksType.WORKS_RECITATION, AWorksType.WORKS_OBB_RECITE,
                AWorksType.WORKS_OBB_RECITE, AWorksType.WORKS_RECITATION,
                AWorksType.WORKS_SING_SONG, AWorksType.WORKS_OBB_SONG,
                AWorksType.WORKS_OBB_SONG, AWorksType.WORKS_SING_SONG,
                33, 49,
                49, 33,
        };
        for (int index = 0; index < tabWorksType.length; index+=2){
            if (worksType == tabWorksType[index]){
                return getBDbsAccount(tabWorksType[index+1], accountName);
            }
        }
        return null;
    }


    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // 查找用户数据库
    public static String getSearchList(BDbsAccount bDbsAccount, byte worksType) {
        return String.format("%ssearch_%s_%s.bin", getDbsPath(bDbsAccount.WorksType), bDbsAccount.AccountName, worksType);
    }
    public static void setSearchUser(BDbsAccount bDbsAccount, byte worksType, BAppUser bAppUser){
        setBAppUser(bAppUser);
        String listFile = getSearchList(bDbsAccount, worksType);
        Object object = MAPI.READ_OBJECT_FILE(listFile);
        List<String> lists = (object instanceof List) ? (List)object : new ArrayList<String>();
        lists.add(bAppUser.UserIdS);
        MAPI.WRITE_OBJECT_FILE(listFile, lists);
    }
    public static void delSearchUser(BDbsAccount bDbsAccount, byte worksType, BAppUser bAppUser){
        String listFile = getSearchList(bDbsAccount, worksType);
        Object object = MAPI.READ_OBJECT_FILE(listFile);
        if (object instanceof List) {
            List<String> lists = (List)object;
            lists.remove(bAppUser.UserIdS);
            MAPI.WRITE_OBJECT_FILE(listFile, lists);
        }
    }
    public static List<BAppUser> getSearchUser(BDbsAccount bDbsAccount, byte worksType){
        String listFile = getSearchList(bDbsAccount, worksType);
        Object object = MAPI.READ_OBJECT_FILE(listFile);
        if (object instanceof List) {
            List<BAppUser> bAppUsers = new ArrayList<>();
            List<String> lists = (List)object;
            int length = lists.size();
            for (int index = 0; index < length; index++){
                String filePath = getUserPath(worksType, lists.get(index));
                Object object1 = MAPI.READ_OBJECT_FILE(filePath);
                if (object1 instanceof BAppUser) {
                    bAppUsers.add((BAppUser)object1);
                }
            }
            return bAppUsers;
        }
        return null;
    }




    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // 上传计划数据库
    public static String getUploadListPath(byte appType, String accountName) {
        return String.format("%sup_%s_list.bin", getDbsPath(appType), accountName);
    }
    public static String getUploadPath(byte appType, String accountName, int planId) {
        return String.format("%sup_%s_%s.bin", getDbsPath(appType), accountName, planId);
    }
    public static void setBUploadPlan(BDbsAccount bDbsAccount, BUploadPlan bUploadPlan){
        String filePath = getUploadPath(bDbsAccount.WorksType, bDbsAccount.AccountName, bUploadPlan.PlanId);
        if (!MAPI.IS_EXIST_FILE(filePath)) {
            String listFile = getUploadListPath(bDbsAccount.WorksType, bDbsAccount.AccountName);
            Object object = MAPI.READ_OBJECT_FILE(listFile);
            List<Integer> lists = (object instanceof List) ? (List)object : new ArrayList<String>();
            Integer planId = bUploadPlan.PlanId;
            lists.add(planId);
            MAPI.WRITE_OBJECT_FILE(listFile, lists);
        }
        MAPI.WRITE_OBJECT_FILE(filePath, bUploadPlan);
    }
    public static void delBUploadPlan(BDbsAccount bDbsAccount, BUploadPlan bUploadPlan){
        String listFile = getUploadListPath(bDbsAccount.WorksType, bDbsAccount.AccountName);
        Object object = MAPI.READ_OBJECT_FILE(listFile);
        if (object instanceof List){
            List<Integer> lists = (List)object;
            Integer planId = bUploadPlan.PlanId;
            lists.remove(planId);
            MAPI.WRITE_OBJECT_FILE(listFile, lists);
        }
        MAPI.DELETE_FILE(getUploadPath(bDbsAccount.WorksType, bDbsAccount.AccountName, bUploadPlan.PlanId));
    }

    public static List<BUploadPlan> getBUploadPlan(BDbsAccount bDbsAccount) {
        String listFile = getUploadListPath(bDbsAccount.WorksType, bDbsAccount.AccountName);
        Object object = MAPI.READ_OBJECT_FILE(listFile);
        if (object instanceof List) {
            List<BUploadPlan> uploadPlans = new ArrayList<>();
            List<Integer> lists = (List) object;
            int length = lists.size();
            for (int index = 0; index < length; index++) {
                Object object1 = lists.get(index);
                if (object1 instanceof Integer) {
                    Object object2 = MAPI.READ_OBJECT_FILE(getUploadPath(bDbsAccount.WorksType, bDbsAccount.AccountName, (Integer)object1));
                    if (object2 instanceof BUploadPlan) {
                        uploadPlans.add((BUploadPlan) object2);
                    }
                }
            }
            return uploadPlans;
        }
        return null;
    }


    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // LOG数据库
    public static String getLogTypListPath(byte appType, LogTyp logTyp, String accountName) {
        return String.format("%s%s_list.bin", getLogPath(appType, logTyp), accountName);
    }
    public static String getLogTypPath(byte appType, LogTyp logTyp, String accountName, String dbsId) {
        return String.format("%s%s_%s.bin", getLogPath(appType, logTyp), accountName, dbsId);
    }
    public static void setDoneLog(BDbsAccount bDbsAccount, LogTyp logTyp, BFileBase bFileBase) {
        bFileBase.DateTime = mMyUtils.getCurrentDate();
        bFileBase.DbsId = String.format("%s", getDbsId());
        String filePath = getLogTypPath(bDbsAccount.WorksType, logTyp, bDbsAccount.AccountName, bFileBase.DbsId);
//        MLOG(String.format("LogA filePath %s %s", bFileBase.DbsId, filePath));
        if (!MAPI.IS_EXIST_FILE(filePath)) {
            String listFile = getLogTypListPath(bDbsAccount.WorksType, logTyp, bDbsAccount.AccountName);
            Object object = MAPI.READ_OBJECT_FILE(listFile);
            List<String> lists = (object instanceof List) ? (List)object : new ArrayList<String>();
            lists.add(bFileBase.DbsId);
            MAPI.WRITE_OBJECT_FILE(listFile, lists);
        }
        MAPI.WRITE_OBJECT_FILE(filePath, bFileBase);
    }
    public static void delDoneLog(BDbsAccount bDbsAccount, LogTyp logTyp, BFileBase bFileBase) {
        String listFile = getLogTypListPath(bDbsAccount.WorksType, logTyp, bDbsAccount.AccountName);
        Object object = MAPI.READ_OBJECT_FILE(listFile);
        if (object instanceof List){
            List<String> lists = (List)object;
            lists.remove(bFileBase.DbsId);
            MAPI.WRITE_OBJECT_FILE(listFile, lists);
        }
        MAPI.DELETE_FILE(getLogTypPath(bDbsAccount.WorksType, logTyp, bDbsAccount.AccountName, bFileBase.DbsId));
    }
    public static List<BFileBase> getDoneLog(BDbsAccount bDbsAccount, LogTyp logTyp){
        String listFile = getLogTypListPath(bDbsAccount.WorksType, logTyp, bDbsAccount.AccountName);
        Object object = MAPI.READ_OBJECT_FILE(listFile);
        if (object instanceof List) {
            List<BFileBase> bFileBases = new ArrayList<>();
            List<String> lists = (List) object;
            int length = lists.size();
            for (int index = 0; index < length; index++) {
                String dbsId = lists.get(index);
                if (dbsId != null) {
                    Object object1 = MAPI.READ_OBJECT_FILE(getLogTypPath(bDbsAccount.WorksType, logTyp, bDbsAccount.AccountName, dbsId));
                    if (object1 instanceof BFileBase) {
                        bFileBases.add((BFileBase) object1);
                    }
                }
            }
            return bFileBases;
        }
        return null;
    }

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // 自由文字数据库
    public static void setFreeInt(int appType, String key, int value){
        setFreeInt(MAPP.mBDbsAccount, appType, key, value);
    }
    public static void setFreeInt(BDbsAccount bDbsAccount, int appType, String key, int value){
        setFreeText(bDbsAccount, appType, key, String.format("%s", value));
    }
    public static int getFreeInt(int appType, String key){
        return Math.abs(getFreeInt(MAPP.mBDbsAccount, appType, key));
    }
    public static int getFreeInt(BDbsAccount bDbsAccount, int appType, String key){
        return Math.abs(MAPI.STRING_DEC32(getFreeText(bDbsAccount, appType, key)));
    }

    public static void setFreeText(int appType, String key, String text){
        setFreeText(MAPP.mBDbsAccount, appType, key, text);
    }
    public static void setFreeText(BDbsAccount bDbsAccount, int appType, String key, String text){
        MAPI.WRITE_OBJECT_FILE(getTextPath(bDbsAccount.WorksType, bDbsAccount.AccountName, appType, key), text);
    }
    public static String getFreeText(int appType, String key){
        return getFreeText(MAPP.mBDbsAccount, appType, key);
    }
    public static String getFreeText(BDbsAccount bDbsAccount, int appType, String key){
        Object object = MAPI.READ_OBJECT_FILE(getTextPath(bDbsAccount.WorksType, bDbsAccount.AccountName, appType, key));
        if (object instanceof String){
            return (String) object;
        }
        return null;
    }

    // 榜单及礼物列表信息
    public static String getRankGiftPath(boolean isGift) {
        if (!isGift) {
            return String.format("%srank_list.bin", getDbsPath((byte) 32));
        }
        return String.format("%sgift_list.bin", getDbsPath((byte)32));
    }
    public static void setRankGiftList(boolean isGift, List<Object> lists){
        MAPI.WRITE_OBJECT_FILE(getRankGiftPath(isGift), lists);
    }
    public static List<Object> getRankGiftList(boolean isGift){
        Object object = MAPI.READ_OBJECT_FILE(getRankGiftPath(isGift));
        if (object instanceof List){
            return  (List)object;
        }
        return null;
    }


    // 运行状态数据库
    public static void setBUsage(int type, BUsage bUsage){      // 0=TOP_LIST 1=type
//        if (bUsage != null) {
//            String topId = String.format("%s", bUsage.LastUsed);
//            setDbsItem(OTHER_RANK_RUN, 2, 0, type, topId, bUsage);
//        }
    }
    public static List<BUsage> getBUsage(int type){
//        List<AItem> lists = (List) getDbsDescList(OTHER_RANK_RUN, 2, 0, type);
//        List<BUsage> bUsages = new ArrayList<>();
//        int length = (lists != null) ? lists.size() : 0;
//        for (int index = 0; index < length; index++){
//            Object object = lists.get(index);
//            if (object instanceof AItem){
//                AItem aItem = (AItem)object;
//                if (aItem.Bean instanceof BFileBase) {
//                    bUsages.add(((BUsage) aItem.Bean));
//                }
//            }else {
//                delDbsAllItem(OTHER_RANK_RUN, 2, 0, type);
//                MTOAST("getBUsage 数据库出错，删除所有");
//                break;
//            }
//        }
//        return bUsages;
        return null;
    }

    public static boolean checkPathExist(String path){
        File file = new File(path);
        boolean pathExist = file.exists();
//        MLOG(String.format("checkPathExist pathA %s %s", pathExist, path));
        if (!pathExist){
            file.mkdirs();
        }
        return file.exists();
    }
}
